home *** CD-ROM | disk | FTP | other *** search
/ SGI Developer Toolbox 6.1 / SGI Developer Toolbox 6.1 - Disc 4.iso / src / exampleCode / games / IndiZone / gold / behaveMeth.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-08-02  |  2.9 KB  |  110 lines

  1. /*
  2.  * The original copyright owners of the accompanying source code files have
  3.  * agreed to place such code into the public domain.  Accordingly, anyone
  4.  * who receives or obtains a copy of such source code is freely entitled to
  5.  * reproduce, use and otherwise exploit such code (including the right to
  6.  * make derivative works), at his/her own risk and expense, without any
  7.  * obligation or liability to the original copyright owners.
  8.  *
  9.  * We would appreciate (but do not require) that the following message be
  10.  * included in any derivative works:
  11.  *
  12.  * "Portions of this program were developed by Peter Broadwell, Rob Myers
  13.  * and Robin Schaufler while working in Silicon Valley."
  14.  *
  15.  * The accompanying source code files and related documentation materials
  16.  * are distributed on an "AS IS" basis, without any warranties or
  17.  * guarantees of any kind.  All implied warranties, including the implied
  18.  * warranties of merchantability and of fitness for any particular purpose,
  19.  * are expressly disclaimed.
  20.  */
  21. #include <stdio.h>
  22. #include <ctype.h>
  23. #include "gl.h"
  24. #include "math.h"
  25. #include "geom.h"
  26. #include "colors.h"
  27. #include "objIds.h"
  28. #include "class.h"
  29. #include "classIds.h"
  30. #include "selectors.h"
  31. #include "mbox.h"
  32. #include "individual.h"
  33. #include "behavior.h"
  34. #include "doers.h"
  35. #include "panel.h"
  36. #include "voxel.h"
  37.  
  38. extern individual *us;
  39. extern individual *curIndiv;
  40. extern long masterClock;
  41. extern panel *makeBHMenu();
  42. extern masterPanel *thePanel;
  43.  
  44. extern subscr *findvars();
  45.  
  46.     /*
  47.      *  add a menu containing a title for self to the panel p
  48.      *  that results in a confirmer allowing you to either dismiss
  49.      *  the confirmer or toss the behavior.
  50.      */
  51. addBHMenu(self, p, name)
  52.     behavior *self;
  53.     panel *p;
  54.     char *name;
  55. {
  56.     int flags;
  57.     point2d buttons;
  58.     rectangle scrArea;
  59.  
  60.     makeobj((Object)name);
  61.     fishColor(PANEL_BLACK);
  62.     rectfi(0,0, strwidth(name), getheight());
  63.     fishColor(PANEL_GRAY5);
  64.     cmov2i(0, 10);
  65.     charstr(name);
  66.     closeobj();
  67.     makeobj((Object)(name+1));
  68.     fishColor(PANEL_GRAY7);
  69.     /*
  70.     recti(2,2, strwidth(name)+4, getheight()+4);
  71.     */
  72.     cmov2i(0, 10);
  73.     charstr(name);
  74.     closeobj();
  75.  
  76.     buttons.x = 1;
  77.     buttons.y = 1;
  78.     flags = NULL;
  79.     setrect(&scrArea, 0,0, strwidth(name), getheight());
  80.     p->kids = makeBHMenu(p->kids, p, flags, &scrArea, &buttons,
  81.                   self, TOSSBEHAVIOR, name, name+1);
  82.  
  83.     /* bump parent's extent */
  84.     p->area.extent.x = max(p->area.extent.x, scrArea.orig.x+scrArea.extent.x);
  85.     p->area.extent.y += scrArea.extent.y;
  86. }
  87.  
  88.     /*
  89.      *  toss self from curIndiv.
  90.      */
  91. tossBehavior(self)
  92.     behavior *self;
  93. {
  94.     emptyPanel(thePanel);
  95.     unsubscribe(self, curIndiv);
  96.     Msg(thePanel, INIT, NOARG, NULL);
  97.     Msg(curIndiv, ADDPANEL, NOARG, NULL);
  98. }
  99.  
  100.     /*
  101.      *  cancel the confirmer.
  102.      */
  103. canConfirmer(self)
  104.     behavior *self;
  105. {
  106.     printf("Can the confirmer.");
  107.     emptyPanel(thePanel);
  108.     Msg(curIndiv, ADDPANEL, PTR, thePanel);
  109. }
  110.